package com.tanhua.server.controller;

import com.tanhua.server.serivce.BaiduService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("/baidu")
public class BaiduController {

    @Autowired
    private BaiduService baiduService;

    /**
     * 上报地理位置
     *    POST  /location
     */
    @PostMapping("/location")
    public ResponseEntity location(@RequestBody Map map) {
        //1、获取请求参数
        Double latitude = (Double) map.get("latitude") ;//纬度
        Double longitude = (Double)  map.get("longitude") ;//经度
        String address = (String) map.get("addrStr") ;//位置
        //2、调用service
        baiduService.location(latitude,longitude,address);
        return ResponseEntity.ok(null);
    }
}
